----------------------------------
--      Module Declaration      --
----------------------------------

local boss = BB["Salramm the Fleshcrafter"]
local mod = BigWigs:New(boss, tonumber(("$Revision: 543 $"):sub(12, -3)))
if not mod then return end
mod.partyContent = true
mod.otherMenu = "Caverns of Time"
mod.zonename = BZ["The Culling of Stratholme"]
mod.enabletrigger = boss 
mod.guid = 26530
mod.toggleoptions = {"flesh", "fleshBar", "bosskill"}

----------------------------------
--         Localization         --
----------------------------------

local L = AceLibrary("AceLocale-2.2"):new("BigWigs"..boss)

L:RegisterTranslations("enUS", function() return {
	cmd = "Salramm",
	flesh = "Twisted Flesh",
	fleshBar = "Twisted Flesh Bar",
	fleshBar_desc = "Show a bar for the duration of the Twisted Flesh curse.",
	flesh_desc = "Warn when someone has the Twisted Flesh curse.",
	flesh_message = "Twisted Flesh: %s",
	ghouls = "Summon Ghouls",
	ghouls_desc = "Warn when Salramm the Fleshcrafter summons ghouls.",
	ghouls_message = "Summoning Ghouls",
}

end )

L:RegisterTranslations("deDE", function() return {
	cmd = "Salramm",
	flesh = "Fluch des verdorbenen Fleisches",
	fleshBar = "Leiste: Fluch des verdorbenen Fleisches",
	fleshBar_desc = "Eine Leiste für die Dauer von Fluch des verdorbenen Fleisches anzeigen.",
	flesh_desc = "Warnen, wenn jemand von Fluch des verdorbenen Fleisches betroffen ist.",
	flesh_message = "Fluch des verdorbenen Fleisches: %s",
	ghouls = "Ghule beschwören",
	ghouls_desc = "Warnen, wenn Salramm der Fleischformer Ghule beschwört.",
	ghouls_message = "Beschwört Ghule",
}

end )

L:RegisterTranslations("esES", function() return {
}

end )

L:RegisterTranslations("esMX", function() return {
}

end )

L:RegisterTranslations("frFR", function() return {
	cmd = "Salramm",
	flesh = "Chair distordue",
	fleshBar = "Chair distordue - Barre",
	fleshBar_desc = "Affiche une barre indiquant la durée de la Malédiction de la chair distordue en cours.",
	flesh_desc = "Prévient quand un joueur subit les effets de la Malédiction de la chair distordue.",
	flesh_message = "Chair distordue : %s",
	ghouls = "Invocation de goules",
	ghouls_desc = "Prévient quand Salramm le Façonneur de chair invoque des goules.",
	ghouls_message = "Goules invoquées",
}

end )

L:RegisterTranslations("koKR", function() return {
	cmd = "살람",
	flesh = "비틀린 살덩이",
	fleshBar = "비틀린 살덩이 바",
	fleshBar_desc = "비틀린 살덩이의 저주가 지속되는 바를 표시합니다.",
	flesh_desc = "비틀린 살덩이의 저주에 걸린 플레이어를 알립니다.",
	flesh_message = "비틀린 살덩이: %s",
	ghouls = "구울 소환",
	ghouls_desc = "살덩이창조자 살람의 구울 소환을 알립니다.",
	ghouls_message = "구울 소환",
}

end )

L:RegisterTranslations("ruRU", function() return {
	cmd = "Салрамм",
	flesh = "Проклятие искаженной плоти",
	fleshBar = "Полоса искаженной плоти",
	fleshBar_desc = "Отображать полосу продолжительности проклятия искаженной плоти.",
	flesh_desc = "Предупреждать, когда на кого либо накладывается проклятие искаженной плоти.",
	flesh_message = "Искаженная плоть: %s",
	ghouls = "Призывание вурдалаков",
	ghouls_desc = "Сообщать, когда Салрамм Плоторез призывает вурдалаков.",
	ghouls_message = "Призывание вурдалаков!",
}

end )

L:RegisterTranslations("zhCN", function() return {
	flesh = "扭曲血肉诅咒",
	fleshBar = "扭曲血肉诅咒计时条",
	fleshBar_desc = "当扭曲血肉诅咒持续时显示计时条。",
	flesh_desc = "当玩家中了扭曲血肉诅咒时发出警报。",
	flesh_message = "扭曲血肉诅咒：>%s<！",
	ghouls = "召唤食尸鬼",
	ghouls_desc = "当塑血者沙尔拉姆召唤食尸鬼时发出警报。",
	ghouls_message = "召唤 食尸鬼！",
}

end )

L:RegisterTranslations("zhTW", function() return {
	cmd = "塞歐朗姆",
	flesh = "扭曲血肉詛咒",
	fleshBar = "扭曲血肉詛咒計時條",
	fleshBar_desc = "當扭曲血肉詛咒持續時顯示計時條。",
	flesh_desc = "當玩家中了扭曲血肉詛咒時發出警報。",
	flesh_message = "扭曲血肉詛咒：>%s<！",
	ghouls = "召喚食屍鬼",
	ghouls_desc = "當『血肉工匠』塞歐朗姆召喚食屍鬼時發出警報。",
	ghouls_message = "召喚 食屍鬼！",
}

end )

----------------------------------
--        Initialization        --
----------------------------------

function mod:OnEnable()
	self:AddCombatListener("SPELL_AURA_APPLIED", "Flesh", 58845)
	self:AddCombatListener("SPELL_AURA_REMOVED", "FleshRemoved", 58845)
	self:AddCombatListener("SPELL_CAST_START", "Ghouls", 52451)
	self:AddCombatListener("UNIT_DIED", "BossDeath")
end

----------------------------------
--        Event Handlers        --
----------------------------------

function mod:Ghouls(_, spellId)
	if self.db.profile.ghouls then
		self:IfMessage(L["ghouls_message"], "Important", spellId)
	end
end

function mod:Flesh(player, spellId)
	if self.db.profile.flesh then
		self:IfMessage(L["flesh_message"]:format(player), "Important", spellId)
	end
	if self.db.profile.fleshBar then
		self:Bar(L["flesh_message"]:format(player), 30, spellId)
	end
end

function mod:FleshRemoved(player)
	if self.db.profile.fleshBar then
		self:TriggerEvent("BigWigs_StopBar", self, L["flesh_message"]:format(player))
	end
end
